#coding=utf-8
import unittest
from selenium import webdriver
from appium import webdriver
from time import sleep
from nav_plugin_op import nav_plugin_factory
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import WebDriverWait
import os
import settings
from Public import BasePage
from Tool.usefulTools import userfulToolsFactory
from Public import BaseConstant
from Tool import DatabaseOperate
from Public import CaseExcelOperate
from Tool import utils_database

#实例化基础数据
navOpenFactory = nav_plugin_factory()
userfulTool = userfulToolsFactory()
element_oprate_instance = BasePage.element_Oprate()
element_find_instances = BasePage.BasicAction()
# basicAction = BasicAction()
dealHelper_parameter = BaseConstant.DisposeCase
database_operate_instances = DatabaseOperate.database_operate()
excel_operate_instances = CaseExcelOperate.excel_Operate()


# nav_name = "工作"
# plugin_name = "案件处置"
nav_name = ["导航栏工作for案件处置",'xpath',"//android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout/android.widget.RadioButton"]
plugin_name = ["插件列表-案件处置",'name','案件处置']
case_item_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/g_base_list']/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]"
case2_item_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/g_base_list']/android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]"
case_item_name = "详情"
detail_map_id = "cn.com.egova.dealhelper:id/task_detail_map_row"#查看地图
exit_map_id = "android:id/action_bar_title"
detail_process_id = "cn.com.egova.dealhelper:id/task_detail_process_row"
exit_process_id = "android:id/up"
task_detail_name = "批转"
task_transist_txtOpinion_name = "请输入意见..."
txtOpinion_name = "批转处理"
add_photo = "cn.com.egova.dealhelper:id/media_view"
add_photo_id = "cn.com.egova.dealhelper:id/tool_photoadd"
select_photo_id = "cn.com.egova.dealhelper:id/id_item_select"
comfirm_photo_id = "cn.com.egova.dealhelper:id/id_select"
submit_id = "cn.com.egova.dealhelper:id/title_right"
comfirm_name = "确定"
task_name = "更多操作"

leader_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/task_seturgent_humanList']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.CheckBox[1]"
reason_name = "请输入设置急要件的原因"
reason_keys_name = "紧急"
submit_id = "cn.com.egova.dealhelper:id/title_right"
scan_suggestion_name = "查看意见"
opinion_name = "授权意见"
start_discuss_name = "发起讨论"
contact_select_name = "其他"
contact_select_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.egovamobile:id/multi_contact_list']/android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.CheckBox[1]"
contact_confirm_id = "cn.com.egova.egovamobile:id/multi_contact_multi_confirm"
exit_discuss_id = "android:id/up"
invalid_case_name = "作废案件"
recovery_case_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/g_base_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]"
register_case_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/g_base_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]"
register_photo_xpath = "//android.widget.GridView[@resource-id='cn.com.egova.dealhelper:id/id_gridView']/android.widget.RelativeLayout[2]/android.widget.ImageButton[1]"
photo_ok_id = "cn.com.egova.dealhelper:id/id_select"
fall_back_case_xpath = "//android.widget.ListView[@resource-id='cn.com.egova.dealhelper:id/g_base_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]"

width = BasePage.Base.driver.get_window_size()['width']
height = BasePage.Base.driver.get_window_size()['height']

#获取当前的登录人员信息
user_infor_excel = excel_operate_instances.get_userInfo(settings.test_case_file,'dispose_case')
user_infor = database_operate_instances.get_human_infor_by_username(user_infor_excel[0])

class dispose_case_factory():

	def open_disposecase_plug(self,driver,file_path):
		# try:
		# 	element_oprate_instance.element_click(nav_name,file_path)
		# 	BasePage.Base.driver.swipe(400,1000,400,50,1200)
		# 	sleep(2)
		# 	driver.swipe(400,400,400,50,1200)
		# 	sleep(5)
		# 	element_oprate_instance.element_click(plugin_name,file_path)
		# 	sleep(5)
		# 	driver.get_screenshot_as_file(file_path + "//open_disposecase_plug_successful.png")
        #
		# except WebDriverException,error:
		# 	print error
		# 	driver.get_screenshot_as_file(file_path + "//open_disposecase_plug_fail.png")
		# 	raise
			# 查找并点击导航栏的插件
			while (True):
				if element_oprate_instance.element_display_commit(plugin_name, settings.pic_file_path):
					element_oprate_instance.element_click(plugin_name, settings.pic_file_path)
					break

				else:
					if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
						BasePage.Base.driver.swipe(400, 400, 400, 50, 1200)
						print u'当前在功能列表界面，可进行操作'
					else:
						print u'当前不在功能列表界面，先调用返回操作'
						try:
							element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
						except Exception, e:
							print e
							print u'执行返回操作'
			sleep(5)
			element_oprate_instance.element_save_pic(settings.pic_file_path, 'open_leaderassign_plug_successful')

	def detail_case(self,driver,file_path):
		try:
			
			sleep(5)
			driver.swipe(400,600,400,50,800)
			driver.find_element_by_xpath(case_item_xpath).click()
			if driver.find_element_by_name(case_item_name.decode("utf-8")).is_displayed():
				driver.get_screenshot_as_file(file_path + "//detail_case_successful.png")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//detail_case_fail.png")
			raise

	def detail_case_map(self,driver,file_path):
		try:
			#在详情页面查看
			sleep(2)
			driver.swipe(400,300,400,50,800)
			sleep(3)
			driver.find_element_by_id(detail_map_id).click()
			driver.get_screenshot_as_file(file_path + "//detail_case_map_successful.png")
			driver.find_element_by_id(exit_map_id).click()

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//detail_case_fail.png")
			raise

	def detail_process_case(self,driver,file_path):
		try:
			#查看办理进度
			driver.swipe(400,300,400,50,800)
			sleep(3)
			driver.find_element_by_id(detail_process_id).click()
			driver.get_screenshot_as_file(file_path + "//detail_process_successful.png")
			driver.find_element_by_id(exit_process_id).click()

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//detail_process_fail.png")
			raise

	def approve_case(self,driver,file_path):
		try:
			#点击批转按钮
			detail_menu_name = element_find_instances.find_element(dealHelper_parameter.dealhelper_detail_menu,settings.pic_file_path).get_attribute('text')
			if detail_menu_name == '批转':
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_detail_menu,settings.pic_file_path)
			else:
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_more_menu, settings.pic_file_path)
				sleep(1)
				driver.find_element_by_name("批转".decode("utf-8")).click()
			# driver.find_element_by_name(task_name.decode("utf-8")).click()
			# driver.find_element_by_name(task_detail_name.decode("utf-8")).click()
			sleep(5)
			#输入意见
			driver.find_element_by_name(task_transist_txtOpinion_name.decode("utf-8")).click()
			driver.find_element_by_name(task_transist_txtOpinion_name.decode("utf-8")).send_keys(txtOpinion_name.decode("utf-8"))
			#添加图片
			driver.find_element_by_id(add_photo).click()
			driver.find_element_by_id(add_photo_id).click()
			driver.find_element_by_id(select_photo_id).click()
			driver.find_element_by_id(comfirm_photo_id).click()
			driver.get_screenshot_as_file(file_path + "//approve_case_picture.png")
			#勾选第一个流向
			element_oprate_instance.element_click(dealHelper_parameter.first_transit_button,settings.pic_file_path)
			#点击提交按钮
			driver.find_element_by_id(submit_id).click()
			driver.find_element_by_name(comfirm_name.decode("utf-8")).click()
			driver.get_screenshot_as_file(file_path + "//approve_case_successful.png")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//approve_case_fail.png")
			raise



	def urgency_case(self,driver):
		try:	
			#设置 急要件
			# sleep(5)
			# driver.swipe(400,1000,400,50,800)
			sleep(2)
			driver.find_element_by_name(task_name.decode("utf-8")).click()
			sleep(2)
			element_oprate_instance.element_click(dealHelper_parameter.urgency_action,settings.pic_file_path)
			sleep(2)
			#勾选--急要件--领导
			driver.find_element_by_xpath(leader_xpath).click()
			driver.find_element_by_name(reason_name.decode("utf-8")).click()
			driver.find_element_by_name(reason_name.decode("utf-8")).send_keys(reason_keys_name.decode("utf-8"))
			driver.find_element_by_id(submit_id).click()
			element_oprate_instance.element_save_pic(settings.pic_file_path,'urgency_case_running')
			driver.find_element_by_name(comfirm_name.decode("utf-8")).click()

		except WebDriverException,error:
			print error
			element_oprate_instance.element_save_pic(settings.pic_file_path, 'urgency_case_failed')
			#返回功能列表界面
			element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button)
			element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button)
			element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button)
			raise

	def suggestion_view(self,driver,file_path):
		try:
			# 查看意见
			# sleep(2)
			driver.find_element_by_name(task_name.decode("utf-8")).click()
			sleep(2)
			driver.find_element_by_name(scan_suggestion_name.decode("utf-8")).click()
			sleep(2)
			if driver.find_element_by_name(opinion_name.decode("utf-8")).is_displayed():
				driver.get_screenshot_as_file(file_path + "//suggestion_view_successful.png")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//suggestion_view_fail.png")
			raise

	def start_discuss(self,driver,file_path):
		try:
			# 发起讨论
			# driver.find_element_by_name(scan_suggestion_name.decode("utf-8")).click()
			sleep(2)
			driver.find_element_by_name(task_name.decode("utf-8")).click()
			sleep(2)
			driver.find_element_by_name(start_discuss_name.decode("utf-8")).click()
			sleep(5)
			driver.find_element_by_name(contact_select_name.decode("utf-8")).click()
 			driver.find_element_by_xpath(contact_select_xpath).click()
 			driver.find_element_by_id(contact_confirm_id).click()
 			sleep(5)
 			driver.tap([(360,1050)],800)
 			driver.get_screenshot_as_file(file_path + "//start_discuss_successful.png")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//start_discuss_fail.png")
			raise

 	def recovery_case(self,driver,file_path):
		try:
			#案件恢复
			# driver.swipe(950,250,240,250,800)
			sleep(3)
			if element_oprate_instance.element_display_commit(dealHelper_parameter.invalid_task_list,settings.pic_file_path):
				element_oprate_instance.element_click(dealHelper_parameter.invalid_task_list,settings.pic_file_path)
			else:
				#横向滑动，寻找作废栏目
				BasePage.Base.driver.swipe(int(0.88*width),int(0.13*height),int(0.22*width),int(0.13*height),800)
				sleep(2)
				#点击 作废案件
				element_oprate_instance.element_click(dealHelper_parameter.invalid_task_list,settings.pic_file_path)
			sleep(5)
			#作废案件页面截图
			driver.get_screenshot_as_file(file_path + "//before_recovery_case.png")
			#点击作废页面第一条案件
			element_oprate_instance.element_click(dealHelper_parameter.dealhelper_first_rec,settings.pic_file_path)
			driver.implicitly_wait(15)
			#获取详情页面左侧按钮名称，并和需要执行的菜单名称进行比较
			detail_menu_name = element_find_instances.find_element(dealHelper_parameter.dealhelper_detail_menu,settings.pic_file_path).get_attribute('text')
			if detail_menu_name =='恢复':
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_detail_menu,settings.pic_file_path)
			else:
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_more_menu,settings.pic_file_path)
				sleep(1)
				driver.find_element_by_name("恢复".decode("utf-8")).click()
			sleep(1)
			driver.find_element_by_name("确定".decode("utf-8")).click()
			sleep(3)
			driver.get_screenshot_as_file(file_path + "//affter_recovery_case.png")
		except Exception, error:
			print error
			driver.get_screenshot_as_file(file_path + "//recovery_case_fail.png")
			raise

 	def register_case(self,driver,file_path):
 		try:
	 		#立案
	 		driver.implicitly_wait(15)
	 		driver.find_element_by_name("立案栏".decode("utf-8")).click()
	 		driver.implicitly_wait(15)
	 		driver.get_screenshot_as_file(file_path + "//before_register_case.png")
	 		driver.find_element_by_xpath(register_case_xpath).click()
	 		sleep(2)
			driver.find_element_by_name("立案".decode("utf-8")).click()
			driver.find_element_by_name("请输入意见...".decode("utf-8")).click()
			driver.find_element_by_name("请输入意见...".decode("utf-8")).send_keys("请求立案".decode("utf-8"))
			driver.find_element_by_id("cn.com.egova.dealhelper:id/media_view").click()
			driver.find_element_by_id("cn.com.egova.dealhelper:id/tool_photoadd").click()
			driver.find_element_by_xpath(register_photo_xpath).click()
			driver.find_element_by_id(photo_ok_id).click()
			sleep(1)
			driver.find_element_by_name("提交".decode("utf-8")).click()
			driver.find_element_by_name("确定".decode("utf-8")).click()
			sleep(3)
			driver.get_screenshot_as_file(file_path + "//affter_ register_case.png")
			
		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//register_case_fail.png")
			raise


	def fall_back(self,driver,file_path):
		try:	
			#案件回退
	 		sleep(2)
			driver.find_element_by_name("更多操作".decode("utf-8")).click()
			driver.find_element_by_name("回退".decode("utf-8")).click()
			driver.find_element_by_name("请输入意见...".decode("utf-8")).click()
			driver.find_element_by_name("请输入意见...".decode("utf-8")).send_keys("请求回退".decode("utf-8"))
			#选择添加附件--相册
			if element_oprate_instance.element_display_commit(dealHelper_parameter.add_attachment_button,settings.pic_file_path):
				element_oprate_instance.element_click(dealHelper_parameter.add_attachment_button,settings.pic_file_path)
				driver.find_element_by_id("cn.com.egova.dealhelper:id/tool_photoadd").click()
				# 勾选图片
				sleep(2)
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_first_photo,settings.pic_file_path)
				element_oprate_instance.element_click(dealHelper_parameter.dealhelper_add_photo_OK,settings.pic_file_path)
			sleep(1)
			#勾选回退的流向参与者
			element_oprate_instance.element_click(dealHelper_parameter.first_transit_button, settings.pic_file_path)
			#点击提交按钮
			driver.find_element_by_name("提交".decode("utf-8")).click()
			driver.find_element_by_name("确定".decode("utf-8")).click()
			sleep(3)
			driver.get_screenshot_as_file(file_path + "//affter_fall_back_case.png")

		except WebDriverException,error:
			print error
			driver.get_screenshot_as_file(file_path + "//fall_back_case_fail.png")
			raise

	#案卷处置界面--案卷筛选
	def deal_helper_filter(self,task_num=None):
		print u'进行案件筛选功能验证'
		#点击案件筛选的按钮
		element_oprate_instance.element_click(dealHelper_parameter.dealhelper_filter_button,settings.pic_file_path)
		#输入需要查询的案件编号
		if task_num:
			element_oprate_instance.element_send_keys(dealHelper_parameter.filter_by_taskNum,task_num,settings.pic_file_path)
		else:
			task_num = database_operate_instances.get_rec_infor_by_menuType('transit','(3,4)',user_infor[0][0])
			element_oprate_instance.element_send_keys(dealHelper_parameter.filter_by_taskNum, task_num[1],settings.pic_file_path)
		# 筛选界面截图
		element_oprate_instance.element_save_pic(settings.pic_file_path,'deal_helper_filter_running')
		#点击确认按钮
		element_oprate_instance.element_click(dealHelper_parameter.dealhelper_filter_OK_button,settings.pic_file_path)
		#筛选成功截图
		element_oprate_instance.element_save_pic(settings.pic_file_path,'deal_helper_filter_successful')
		# #点击打开搜索结果--第一条案件
		# element_oprate_instance.element_click(dealHelper_parameter.dealhelper_first_rec,file_path)

	#点击列表的第一条案件
	def dealhelp_first_rec_click(self):
		sleep(2)
		#获取当前第一条案件的任务号
		task_num = element_find_instances.find_element(dealHelper_parameter.task_num_location,settings.pic_file_path).get_attribute('text')
		print u'当前操作的案件号为： '+str(task_num)
		# 点击打开搜索结果--第一条案件
		element_oprate_instance.element_click(dealHelper_parameter.dealhelper_first_rec,settings.pic_file_path)
		#案件详情页面打开之后截图
		element_oprate_instance.element_save_pic(settings.pic_file_path,'dealhelp_first_rec_click_detail'+task_num)

	#返回功能列表
	def back_to_function_list(self):
		#点击左上角的回退按钮
		sleep(3)
		element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)









dispose_case_factory_instances = dispose_case_factory()
class DealHelper_Module():
	#案件处置--案件批转
	def dealHelper_rec_transit(self):
		#打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver,settings.pic_file_path)
		#获取可批转的案件
		task_num = database_operate_instances.get_rec_infor_by_menuType('transit','(3,4)',user_infor[0][0])
		#进行案件筛选获取
		dispose_case_factory_instances.deal_helper_filter(task_num[1])
		#打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#进行批转操作：
		dispose_case_factory_instances.approve_case(BasePage.Base.driver,settings.pic_file_path)
		#返回功能列表
		dispose_case_factory_instances.back_to_function_list()

	#设置急要件
	def dealHelper_set_urgency(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用2次返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行了2次返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 获取可批转的案件
		task_num = database_operate_instances.get_rec_infor_by_menuType('transit', '(3,4)',user_infor[0][0])
		# 进行案件筛选获取
		dispose_case_factory_instances.deal_helper_filter(task_num[1])
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#进行急要件设置操作
		dispose_case_factory_instances.urgency_case(BasePage.Base.driver)
		#返回案件处置列表界面
		dispose_case_factory_instances.back_to_function_list()
		# 返回到功能列表界面
		dispose_case_factory_instances.back_to_function_list()

	#作废案件恢复
	def dealHelper_rec_recovery(self):
		#先根据当前的人员信息获取是否有配置作废箱子
		#从Excel表格获取当前插件适用的用户
		user_infor = excel_operate_instances.get_userInfo(settings.test_case_file,'dispose_case')
		# 获取人员信息，包括 human_id等信息
		human_infor = database_operate_instances.get_human_infor_by_username(user_infor[0])
		#根据humanid 获取人员的tasklist，检查是否包含作废栏
		task_list = database_operate_instances.get_tasklist_infor(human_infor[0][0],'3')
		for task_list_id in range(len(task_list)):
			#不包含作废栏则继续循环
			if 'rec_recyclelist' not in task_list[task_list_id]:
				if task_list_id == len(task_list) - 1:
					print u'该人员无作废箱子，请先进行配置或是切换人员'
					raise
				else:
					continue
			else:
				print u'当前用户包含作废栏，进一步检查是否包含作废案件'
				rec_list = utils_database.data_seach_by_sql(task_list[task_list_id][4])
				if len(rec_list) > 0:
					while (True):
						if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
							print u'当前在功能列表界面，可进行操作'
							break
						else:
							print u'当前不在功能列表界面，先调用2次返回操作'
							try:
								element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
							except Exception, e:
								print e
								print u'执行了2次返回操作'
					#调用打开案件处置插件
					dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
					#调用案件恢复操作
					dispose_case_factory_instances.recovery_case(BasePage.Base.driver, settings.pic_file_path)
					#调用返回功能列表操作
					dispose_case_factory_instances.back_to_function_list()
				else:
					print u'无可进行恢复的作废案件，请调整人员或是进行数据准备'
					raise
				break

	#打开案件详情
	def dealHelper_rec_detailInfor(self):
		#先进行检查当前的页面是否为功能列表界面
		while(True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用2次返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行了2次返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#返回案件列表，返回功能列表
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()

	# 打开案件详情
	def dealHelper_detail_case_map(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用2次返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行了2次返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#查看地图
		dispose_case_factory_instances.detail_case_map(BasePage.Base.driver,settings.pic_file_path)
		# 返回案件列表,返回功能列表
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()

	# 查看办理进度
	def dealHelper_detail_process_case(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行了2次返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#查看办理进度
		dispose_case_factory_instances.detail_process_case(BasePage.Base.driver,settings.pic_file_path)
		# 返回案件列表,返回功能列表
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()

	#发起讨论
	def dealHelper_start_discuss(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#查看办理进度
		dispose_case_factory_instances.start_discuss(BasePage.Base.driver, settings.pic_file_path)
		# 返回案件列表,返回功能列表
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()

	#查看意见
	def dealHelper_suggestion_view(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行返回操作'
		# 打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver, settings.pic_file_path)
		# 打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#查看办理进度
		dispose_case_factory_instances.suggestion_view(BasePage.Base.driver, settings.pic_file_path)
		# 返回案件列表,返回功能列表
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()
		dispose_case_factory_instances.back_to_function_list()

	#案件回退
	def dealHelper_rec_rollback(self):
		# 先进行检查当前的页面是否为功能列表界面
		while (True):
			if element_oprate_instance.element_display_commit(nav_name, settings.pic_file_path):
				print u'当前在功能列表界面，可进行操作'
				break
			else:
				print u'当前不在功能列表界面，先调用返回操作'
				try:
					element_oprate_instance.element_click(dealHelper_parameter.dealhelper_back_button,settings.pic_file_path)
				except Exception, e:
					print e
					print u'执行返回操作'
		#打开案件处置插件
		dispose_case_factory_instances.open_disposecase_plug(BasePage.Base.driver,settings.pic_file_path)
		#获取可批转的案件
		task_num = database_operate_instances.get_rec_infor_by_menuType('rollback','(3,4)',user_infor[0][0])
		#进行案件筛选获取
		dispose_case_factory_instances.deal_helper_filter(task_num[1])
		#打开案件详情页面
		dispose_case_factory_instances.dealhelp_first_rec_click()
		#进行回退操作：
		dispose_case_factory_instances.fall_back(BasePage.Base.driver,settings.pic_file_path)
		#返回功能列表
		dispose_case_factory_instances.back_to_function_list()


	# def urgency_case(self,driver,file_path):

if __name__ == '__main__':
	unittest.main()





